package com.wlr.study.leetcode;

public class LeetCode1137 {

    public int tribonacci(int n) {
        if (n == 0) {
            return 0;
        }
        if (n <= 2) {
            return 1;
        }
        int result = 0, start = 0, preNum = 1, currNum = 1;
        for (int i = 3; i <= n; i++) {
            result = preNum + currNum + start;
            start = preNum;
            preNum = currNum;
            currNum = result;
        }
        return result;
    }

    public static void main(String[] args) {
        LeetCode1137 leetCode1137 = new LeetCode1137();
        System.out.println(leetCode1137.tribonacci(25));
    }
}
